package com.qf.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @propram: IntelliJ IDEA
 * @description: 解决JavaScript的为了安全出现的跨域问题，给所有的响应头加上
 * @author: 秦先发
 * @create: 2021-09-24 17:11
 **/
@Configuration
public class CORSConfig {
    @Bean
   public WebMvcConfigurer corsconfigurer(){
        return  new WebMvcConfigurer(){
            @Override
            public void addCorsMappings(CorsRegistry registry) {
                registry.addMapping("/**")
                        .allowedHeaders("*")
                        .allowedMethods("POST","GET","DELETE","PUT")
                        .allowedOrigins("*");
            }
        };
    }

}
